<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">
   			<span class="layui-breadcrumb" lay-filter="breadcrumb">
              <a href="javascript:;">基础信息</a>
              <a href="javascript:;">相关协议</a>
              <a ><cite>编辑协议</cite></a>
            </span>
            <div class="layui-inline" style="float:right;">
                <button type="button" class="layui-btn layui-btn-sm"  onclick="history.go(-1);">返回列表</button>
            </div>
        </div>
        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" id="agreeAddForm">
                <input type="hidden" name="type" value="${agree.type}">
                <div class="layui-form-item">
                    <label class="layui-form-label">协议标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" autocomplete="off" class="layui-input" value="${agree.title}" placeholder="请输入协议标题">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">协议内容</label>
                    <div class="layui-input-block">
                        <textarea id="content" name="content" style="display: none">${agree.content}</textarea>
                        <script id="articleEditor" type="text/plain" style="width:100%;height:400px;"></script>
                    </div>
                </div>
            </form>
            <div class="layui-form-item layui-layout-admin">
                <div class="layui-input-block">
                    <div class="layui-footer" style="left: 0;">
                        <button class="layui-btn" onclick="saveAgree()">保存</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.form.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/js/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" src="/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
    layui.config({
        //静态资源所在路径
        base: '/layuiadmin/'
    }).extend({
        //主入口模块
        index: 'lib/index'
    }).use(['index', 'form'], function(){
        var $ = layui.$,layer = layui.layer,element = layui.element;
    });

    $(function () {
        var ue = UE.getEditor('articleEditor');
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function(action) {
            if (action == '/uploadFile') {
                return '/base/uploadRichFile';
            } else {
                return this._bkGetActionUrl.call(this, action);
            }
        };
        UE.getEditor('articleEditor').ready(function() {
            UE.getEditor('articleEditor').setContent($("#content").text());
        })
    });

    function saveAgree(){
        $("#content").text(UE.getEditor('articleEditor').getContent());
        var tabIndex = 2;
        $.ajax({
            url: "/sys/doEditAgreement",
            data: $('#agreeAddForm').serialize(),
            dataType: "json",
            type: "post",
            traditional: true,
            success: function (data) {
                if (data.status) {
                    layer.msg(data.desc);
                    setTimeout(function () {
                        window.location.href = "/sys/baseInfo?tabIndex=" + tabIndex;
                    }, 1000)
                }
            }
        });
    }
</script>
</body>
</html>